package com.lunhui.service.lunhui.service.business.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lunhui.map.client.MapClient;
import com.lunhui.map.client.dto.MapInfoDto;
import com.lunhui.service.lunhui.service.business.MapService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author renminghe-kg
 */
@Service("mapService")
public class MapServiceImpl implements MapService {
    private static final Logger logger = LoggerFactory.getLogger(MapServiceImpl.class);

    @Reference
    private MapClient mapClient;

    @Value("${spring.dubbo.registry.address:}")
    private String address;

    @Value("${spring.dubbo.provider.version:}")
    private String version;

    private int pageNo = 0;
    private int pageSize = 25;

    @Override
    public PageInfo<MapInfoDto> getMapInfo(int areaId, int sceneId) throws RuntimeException {

        try {
            PageHelper.startPage( pageNo , pageSize );

            List<MapInfoDto> mapInfoDtoList = mapClient.getMapInfo(areaId, sceneId);

            return new PageInfo<>(mapInfoDtoList);

        } catch (Exception e) {
            logger.error("获取map服务地图数据失败: " + e);
            throw new RuntimeException(e);
        }
    }
}